<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Raines Blog</title>

    <!--加载顶部页面的js-->
    <script src="projectComm/headComm.js"></script>
    <!-- Bootstrap core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom fonts for this template -->
    <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet'
          type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800'
          rel='stylesheet' type='text/css'>

    <!-- Custom styles for this template -->
    <link href="css/clean-blog.min.css" rel="stylesheet">


</head>

<body>

<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav">

</nav>

<!-- Page Header -->
<header class="masthead" style="background-image: url('img/python.jpg')">
    <div class="overlay"></div>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-12 mx-auto">
                <div class="post-heading">
                    <h1>linux环境安装python3.x</h1>
                    <h2 class="subheading">文章使用3.5.2版本</h2>
                    <span class="meta">Posted by
              <a href="#">Raines</a>
              on January 22, 2019</span>
                </div>
            </div>
        </div>
    </div>
</header>

<!-- Post Content -->
<article>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-10 mx-auto">
                <p>查看当前Python版本号:</br>
                    Python -V </br>
                    注意:此处是大写字母V,如果不慎按成小写,可以控制台输入exit()函数离开.</br>
                    </br></p>
                <h3>下载新版本:</h3>
                <p></br>
                    1.去https://www.python.org/ftp/python/选择一个合适的版本</br>
                    例如:</p>
                <h4>wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz </br></h4>
                <p>2.下载完成后解压</br></p>
                <h4>tar -zxvf Python-3.5.2.tgz</br></h4>
                <p>3.进入解压后的目录,安装配置</p>
                <h4>cd Python-3.5.2/</h4>
                <h4>./configure</h4>
                <p>执行 ./configure 时，如果报error:</p>
                <p>configure: error: no acceptable C compiler found in $PATH</p>
                <p>说明没有安装合适的编译器。这时，需要安装/升级 gcc 及其它依赖包。</p>
                <h4>yum install make gcc gcc-c++</h4>
                <p>安装完成后重新执行</p>
                <h4>./configure</h4>
                <p>4.配置完成后,就开始编译了</p>
                <h4>make</h4>
                <p>完成后,开始安装</p>
                <h4>make install</h4>
                <h3>注意:</h3>
                <p>执行make install时,如果报error:
                    ModuleNotFoundError: No module named '_ctypes'
                    3.7版本需要一个新的包libffi-devel，安装此包之后再次进行编译安装即可。</p>
                <h4>yum install libffi-devel -y</h4>
                <h4>make install</h4>
                <hr/>
                <p>此时用python -V命令查看版本,发现还是2.x版本,是因为python命令优先选择python2,此时使用python3 -V发现安装的为新版本.</br>
                    如果不替换默认的python2的话,使用python和pip系列命令都需要加上数字3</p>
                <!--<a href="#">-->
                <!--<img class="img-fluid" src="img/post-sample-image.jpg" alt="">-->
                <!--</a>-->
                <!--<span class="caption text-muted">To go places and do things that have never been done before – that’s what living is all about.</span>-->

                <!--<p>Placeholder text by-->
                <!--<a href="http://spaceipsum.com/">Space Ipsum</a>. Photographs by-->
                <!--<a href="https://www.flickr.com/photos/nasacommons/">NASA on The Commons</a>.</p>-->
            </div>
        </div>
    </div>
</article>

<hr>

<!-- Footer -->
<footer>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-10 mx-auto">
                <ul class="list-inline text-center">
                    <li class="list-inline-item">
                        <a href="#">
                  <span class="fa-stack fa-lg">
                    <i class="fas fa-circle fa-stack-2x"></i>
                    <i class="fab fa-twitter fa-stack-1x fa-inverse"></i>
                  </span>
                        </a>
                    </li>
                    <li class="list-inline-item">
                        <a href="#">
                  <span class="fa-stack fa-lg">
                    <i class="fas fa-circle fa-stack-2x"></i>
                    <i class="fab fa-facebook-f fa-stack-1x fa-inverse"></i>
                  </span>
                        </a>
                    </li>
                    <li class="list-inline-item">
                        <a href="https://github.com/Xiaolong00">
                  <span class="fa-stack fa-lg">
                    <i class="fas fa-circle fa-stack-2x"></i>
                    <i class="fab fa-github fa-stack-1x fa-inverse"></i>
                  </span>
                        </a>
                    </li>
                </ul>
                <p class="copyright text-muted">Copyright &copy; Your Website 2018</p>
            </div>
        </div>
    </div>
</footer>

<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

<!-- Custom scripts for this template -->
<script src="js/clean-blog.min.js"></script>


</body>

</html>
